//
//  MainTabView.swift
//  WeChatClient
//
//  Created by AI Assistant on 2025/10/31.
//

import SwiftUI

struct MainTabView: View {
    @StateObject private var chatViewModel = ChatViewModel()
    @StateObject private var contactsViewModel = ContactsViewModel()
    @StateObject private var discoverViewModel = DiscoverViewModel()
    @StateObject private var profileViewModel = ProfileViewModel()
    
    var body: some View {
        TabView {
            ChatListView()
                .environmentObject(chatViewModel)
                .tabItem {
                    Image(systemName: "message.fill")
                    Text("微信")
                }
                .badge(chatViewModel.totalUnreadCount > 0 ? chatViewModel.totalUnreadCount : 0)
            
            ContactsView()
                .environmentObject(contactsViewModel)
                .tabItem {
                    Image(systemName: "person.2.fill")
                    Text("通讯录")
                }
            
            DiscoverView()
                .environmentObject(discoverViewModel)
                .tabItem {
                    Image(systemName: "safari.fill")
                    Text("发现")
                }
            
            ProfileView()
                .environmentObject(profileViewModel)
                .tabItem {
                    Image(systemName: "person.fill")
                    Text("我")
                }
        }
        .accentColor(.green)
    }
}
